import Vue from 'vue'
import VueRouter from 'vue-router'
import filters from './filters'
import RouterMap from './router'
import FastClick from 'fastclick'

Vue.config.silent = false;
Vue.use(VueRouter);
//实例化Vue的filter
Object.keys(filters).forEach(k => Vue.filter(k, filters[k]))
//实例化VueRouter
var router = new VueRouter({
    hashbang: true,
    history: false,
    saveScrollPosition: false,
    transitionOnLoad: true
});
//配置服务地址
// window.BaseServerUrl = 'http://172.17.18.132:8080/UserService/';
// window.SoftCodeUrl = "http://172.17.18.132:8080/UserService/softcode";
window.BaseServerUrl = 'https://www.58xcl.com/ns/';
window.SoftCodeUrl = "https://www.58xcl.com/ns/softcode";
window.UploadimgUrl = "http://172.17.18.132/Upload/UploadService";
window.IsDev = true;//开发模式
//路由重定向
router.beforeEach((transition) => {
    FastClick.attach(document.body);
    if (transition.to.auth) {
        if (localStorage.token) {
            transition.next();
        } else {
            var redirect = encodeURIComponent(transition.to.path);
            transition.redirect('/Login?redirect=' + redirect);
        }
    } else {
        transition.next();
    }
});

RouterMap(router);

let App = Vue.extend({});
router.start(App, '#app');

